package com.ndood.spider.taobaomix.action;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.springframework.stereotype.Component;

import com.ndood.core.render.SeleniumDriverAction;
import com.ndood.core.util.WindowUtil;

@Component
public class TaobaoMixAction implements SeleniumDriverAction {

    @Override
    public void execute(WebDriver driver) {
    	try {
    		// 触发页面延时加载内容
    		WindowUtil.loadAll(driver);
			Thread.sleep(5000);
			
			// 如果用的是chrome headless，且是视频则点击
			WebElement button = driver.findElement(By.className("J_playVideo"));
			if(button!=null&&(driver instanceof ChromeDriver)){
				button.click();
				Thread.sleep(3000);
			}
			
    	} catch (Exception e) {
			e.printStackTrace();
		}
    }
}
